const {transformStart,handleTitle} = require("../../utils/index")
Page({
  data:{
    arr:"",
    star:""
  },
  onLoad(){
    wx.request({
      url: 'http://192.168.4.20:8000/top250',
      header: {'content-type':'application/json'},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result)=>{
        this.handleHttpData(result.data.result)
      }
    });
  },
  handleHttpData(res){
    res.forEach(item=>{
      item.title = handleTitle(item.title)
      item.star =transformStart(item.raiting)
    })
    this.setData({
      arr:res
    })
  },
  handleClick(event){
    let id = event.currentTarget.dataset.aid
    wx.navigateTo({
      url: `/pages/movieDetail/movieDetail?id=${id}`
    });
  }
})